package com.etong.citymap.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {

	public static String setSimpleDateFormat(Date date, String format) {
		if (date != null) {
			SimpleDateFormat zhuanh = new SimpleDateFormat(format);
			return zhuanh.format(date);
		}
		return "";
	}

	public static Date setStringToDate(String format, String date)
			throws Exception {
		SimpleDateFormat zhuanh = new SimpleDateFormat(format);
		return zhuanh.parse(date);
	}
	
	public static Date addDay(Date date,int days) {
		Calendar cal=Calendar.getInstance(); 
		cal.setTime(date);
		cal.add(Calendar.DAY_OF_MONTH, days);//取当前日期的前一天. 
		return cal.getTime();
	}

}
